
import 'package:amway_superapp_creator_plugin/viewmodels/test_photo_sel_model.dart';
import 'package:amway_superapp_creator_plugin/views/base_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:provider/provider.dart';

class TestSelPhotoView extends StatefulWidget {
  @override
  _TestSelPhotoViewState createState() => _TestSelPhotoViewState();
}

class _TestSelPhotoViewState extends State<TestSelPhotoView>
    {
  @override
  Widget build(BuildContext context) {
    return BaseView(
        model: TestSelPhotoViewModel(api: Provider.of(context)),
        builder: (context, model, child) => Scaffold(
              appBar: AppBar(
                title: Text('图像选择测试'),
                centerTitle: true,
              ),
              body: Container(
                child: Center(
                  child: Column(
                    children: [
                      MaterialButton(
                        onPressed: () {
                        },
                        child: Text('选择图片'),
                        color: Colors.blue,
                      ),
                      MaterialButton(
                        onPressed: () {
                        },
                        child: Text('选择图片视频拍照录视频'),
                        color: Colors.blue,
                      ),
                      model.file == null
                          ? Icon(Icons.add)
                          : Image.file(model.file),

                    ],
                  ),
                ),
              ),
            ));
  }

  @override
  Widget buildBigImageLoading(
      BuildContext context, AssetEntity entity, Color themeColor) {
    return Center(
      child: Container(
        width: 50.0,
        height: 50.0,
        child: CupertinoActivityIndicator(
          radius: 25.0,
        ),
      ),
    );
  }

  @override
  Widget buildPreviewLoading(
      BuildContext context, AssetEntity entity, Color themeColor) {
    return Center(
      child: Container(
        width: 50.0,
        height: 50.0,
        child: CupertinoActivityIndicator(
          radius: 25.0,
        ),
      ),
    );
  }
}

